package com.kkzyxx.user.controller;

import com.kkzyxx.user.model.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

/**
 * Created by xl on 2017/5/10.
 */
public class Provider {

    public List<User> getUser()
    {
        SqlSession session = openSession();
        String __getUser__ = "getUser";
        return session.selectList(__getUser__);
    }

    public SqlSession openSession()
    {
        String resource = "Configuration.xml";
        InputStream is = Provider.class.getClassLoader().getResourceAsStream(resource);
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
        SqlSession session = sessionFactory.openSession();
        return session;
    }
}
